package com.cxyzy.colorpickerdemo

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.flask.colorpicker.builder.ColorPickerDialogBuilder
import kotlinx.android.synthetic.main.activity_main.*


class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        mainLayout.setOnClickListener {
            showColorPicker()
        }
    }

    private fun showColorPicker() {
        ColorPickerDialogBuilder
            .with(this)
            .setTitle("Choose color")
            .initialColor(getColor(R.color.colorPrimary))
            .setPositiveButton("ok")
            { _, selectedColor, _ -> colorTv.setBackgroundColor(selectedColor) }
            .build()
            .show()
    }
}
